package com.tianshuo.construct.main;

import com.tianshuo.construct.ConstructConfig;
import com.tianshuo.construct.model.Animal;
import com.tianshuo.construct.model.Cat;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;

/**
 * 不使用配置类
 * 直接使用扫描器配置扫描地址
 */
public class ScannerApplicationContext {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        ClassPathBeanDefinitionScanner classPathBeanDefinitionScanner = new ClassPathBeanDefinitionScanner(applicationContext);
        classPathBeanDefinitionScanner.scan("com.tianshuo.construct");



        applicationContext.refresh();
        Animal animal = applicationContext.getBean(Animal.class);
        System.out.println(applicationContext.getBean(Cat.class));

        System.out.println(animal.getCat());



    }
}
